<template>
	<div v-show="show">
		<u-navbar v-if="show" title="首页" bgColor="#F3F4F6" :titleStyle="{'color':'#000000','font-size':'18px','font-weight':'500'}" :fixed="true">
			<view slot="left"></view>
		</u-navbar>
		<!-- <mescroll-body ref="mescrollRef" :top="listTop" :down="downOption" :up="upOption" :bottom="listBottom"
			@init="mescrollInit" @down="downCallback" @up="upCallback">
			<block v-for="(item,index) in activitys" :key="index">
				<activity-cell :data="item"></activity-cell>
			</block>
		</mescroll-body> -->
		<view :style="{'margin-top':listTop+'rpx'}">
			<block v-for="(item,index) in activitys" :key="index">
				<activity-cell :data="item"></activity-cell>
			</block>
		</view>
	</div>
</template>

<script>
	var globalData=getApp({allowDefault: true}).globalData
	import * as homeApi from '../../api/user/home.js'
	import activityCell from '../components/activityCell.nvue';
	import yyRefresh from '@/components/yy-refresh/yy-refresh.nvue';
	import yyLoadMore from '@/components/yy-refresh/yy-load-more.nvue';
	import MescrollMixin from "@/components/mescroll-uni/components/mescroll-uni/mescroll-mixins.js"
	import mescrollBody from "@/components/mescroll-uni/components/mescroll-body/mescroll-body.vue"
	import vShow from 'weex-v-show'
	import {paging} from '@/mixins/paging.js'
	import { convertRpx } from '@/utils/util.js'
	import user from '@/common/js/user.js';
	// #ifdef APP-NVUE
	Vue.directive('show', vShow)
	// #endif
	export default {
		mixins:[MescrollMixin,paging],
		components: {
			activityCell,
			mescrollBody
		},
		props:{
			show:{
				type:Boolean,
				default:true
			}
		},
		data() {
			return {
				listTop:0,
				navHeight:0,
				showEmpty:true,
				emptyTop:0,
				activitys:[],
				listStyle: {
					'width':380,
					'height': 712
				},
				query: {
					pageSize: 100,
					pageNum: 1
				},
				refreshText: ['下拉刷新', '释放更新', '刷新中...', '刷新成功'],
				loadMoreText: ['', '加载中...', '没有更多啦']
			}
		},
		mounted() {
			this.navHeight=globalData.titleHeight;
			this.emptyTop=globalData.windowHeight/2.0-60;
			this.listStyle['width']=globalData.windowWidth-30;
			this.listStyle['height']=globalData.windowHeight-this.navHeight;
			this.listTop=convertRpx(this.navHeight);
			// #ifdef MP
			this.getActivityList()
			// #endif
		},
		methods: {
			// #ifdef MP
			upCallback(page) {
				// this.mescroll.resetUpScroll()
				this.getActivityList()
			},
			getActivityList(){
				homeApi.getAcitivityInfo().then((res) => {	
					if (res.code == 0) {		
						this.activitys =res.data
						// this.mescroll.endSuccess(res.data.length, true)
					}		
				}).catch((errMsg) => {
					// this.mescroll.endErr();
				})
			},
			// #endif
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		margin: 0rpx 30rpx;
	}
	.listStyle{
		
	}
</style>